//
//  UIRelated.m
//  STM
//
//  Created by  xuchen(陈旭)， xichen(陈曦)， qq：511272827 on 10-10-21.
//  Copyright 2010 cc_team.com. All rights reserved.
//
#include "CCAll.h"

#ifdef	OBJC_MACRO

#import "CCUIRelated.h"

@implementation UIRelated

//创建系统等待状态图标
+ (UIActivityIndicatorView *)createWaitingIcon:(CGRect)rect
{	
	UIActivityIndicatorView *waitingIcon = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
	waitingIcon.frame = rect;
	[waitingIcon autorelease];
	
	return waitingIcon;
}

//显示系统的昂带状态图标
+ (void)showWaitingIcon:(UIActivityIndicatorView *)waitingIcon
{
	waitingIcon.hidden = NO;
	[waitingIcon startAnimating]; 
}

//隐藏系统的昂带状态图标
+ (void)hideWaitingIcon:(UIActivityIndicatorView *)waitingIcon
{
	waitingIcon.hidden = YES;
	[waitingIcon stopAnimating];
}

//获取UITextView的ContentSize的宽度
+ (CGFloat)getUITextViewContentWidth:(UITextView *)textView
{
	return textView.contentSize.width;
}

//获取UITextView的ContentSize的高度
+ (CGFloat)getUITextViewContentHeight:(UITextView *)textView
{
	return textView.contentSize.height;
}

//设置UIView的Frame的Y坐标
+ (CGFloat)setUIViewYValue:(UIView *)view withYValue:(CGFloat)yValue
{
	CGRect rect = view.frame;
	
	//获取旧的Y坐标
	CGFloat oldY = rect.origin.y;
	
	rect.origin.y = yValue;	
	view.frame = rect;
	
	return oldY;
}

//设置UIView的Frame的高度
+ (CGFloat)setUIViewHeight:(UIView *)view withHeight:(CGFloat)newHeight
{
	if(newHeight < 0)
	{
		NSLog(@"set setUIViewContentHeight below zero! %f", newHeight);
	}
	
	CGRect rect = view.frame;
	
	//获取旧的高度
	CGFloat oldHeight = rect.size.height;
	
	rect.size.height = newHeight;	//设置新的高度；这么做的原因在于：不能用view.frame.size.height = newHeight;
	view.frame = rect;
	
	return oldHeight;
}

@end

#endif
